package com.ren.stuyspringbootmore.config;

import com.ren.stuyspringbootmore.conponent.LoginHandlerIntercepor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;


@Configuration
public class  HanderConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //需要拦截的路径，/**表示需要拦截所有请求
        String[] addPathPatterns = {"/**"};
        //不需要拦截的路径
        String[] excludePathPaterns = {
                "/",
                "/login"

        };
        //注册一个登录拦截器
        registry.addInterceptor(new LoginHandlerIntercepor())
                .addPathPatterns(addPathPatterns).excludePathPatterns(excludePathPaterns);
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
    }

}
